package com.example.zhaoping.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.zhaoping.entity.PageParam;
import com.example.zhaoping.entity.Recruitment;
import com.example.zhaoping.mapper.RecruitmentMapper;
import com.example.zhaoping.service.RecruitmentSerice;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RecruitmentServiceImpl implements RecruitmentSerice {
    @Resource
    private RecruitmentMapper recruitmentMapper;
    @Override
    public Page<Recruitment> getJob(int eid, PageParam param) {
        Page<Recruitment> page = new Page<>(param.getPageNum(),param.getPageSize());
        QueryWrapper<Recruitment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("eid",eid);
        if(param.getKeyword()!=null){
            //多字段模糊查询
            queryWrapper.and(goodsQueryWrapper ->
                    goodsQueryWrapper.like("job",param.getKeyword()));
        }
        return recruitmentMapper.selectPage(page,queryWrapper);
    }

    @Override
    public int delJob(List list) {
        return recruitmentMapper.deleteBatchIds(list);
    }

    @Override
    public int addJob(Recruitment recruitment) {
        return recruitmentMapper.insert(recruitment);
    }

    @Override
    public int editJob(Recruitment recruitment) {
        return recruitmentMapper.updateById(recruitment);
    }

    @Override
    public Recruitment getJobById(int id) {
        return recruitmentMapper.selectById(id);
    }


}
